import React from "react";
import { Route, Switch, Redirect } from "react-router-dom";
import FrameOut from "@/components/frame-out/frame-out";

import { privateRoutes } from "./routers";
class App extends React.Component {
  constructor(props) {
    super(props);
    this.state = {};
  }
  render() {
    //显示私有的路由 /admin 二级路由

    return (
      <FrameOut>
        <Switch>
          {privateRoutes.map((item, index) => {
            return (
              <Route
                path={item.pathname}
                key={index}
                render={(rootProps) => {
                  return <item.component {...rootProps} />;
                }}
              ></Route>
            );
          })}
          <Redirect
            from="/admin"
            to={privateRoutes[0].pathname}
            exact
          ></Redirect>
          <Redirect from="*" to="/404"></Redirect>
        </Switch>
      </FrameOut>
    );
  }
}

export default App;
